fix: merge case-duplicate github repos and enforce unique lower(url) [CM-1344]#4383
Conversation
…ueness Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
PR SummaryHigh Risk Overview The first migration runs atomically: picks a keeper per The second migration adds a partial unique index Reviewed by Cursor Bugbot for commit ac4dc81. Bugbot is set up for automated code reviews on this repo. Configure here. |
|
|
There was a problem hiding this comment.
Pull request overview
Consolidates case-duplicate GitHub repositories and prevents recurrence.
Changes:
- Re-points dependent records and removes duplicate repositories.
- Normalizes surviving GitHub URLs.
- Adds case-insensitive uniqueness enforcement.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
Comments suppressed due to low confidence (1)
backend/src/osspckgs/migrations/V1784718693__merge_case_duplicate_github_repos.sql:101
urlis the Tinybirdrepossorting key (services/libs/tinybird/datasources/repos.datasource:74). This update therefore inserts a new lowercase key but cannot replace the previously ingested mixed-case key;FINALkeeps both, and joins by repo ID can duplicate downstream results. Include a Tinybird cleanup/rebuild or tombstone path for the old URLs.
UPDATE repos r
SET url = LOWER(r.url), updated_at = NOW()
WHERE r.host = 'github'
AND r.url <> LOWER(r.url);
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit eff5795. Configure here.
| FROM repos r | ||
| WHERE r.host = 'github' | ||
| AND p.repository_url = r.url | ||
| AND p.repository_url <> LOWER(p.repository_url); |
There was a problem hiding this comment.
Case-sensitive package URL join
Medium Severity
The migration lowercases packages.repository_url only when it equals a GitHub repos.url byte-for-byte. GitHub URLs are case-insensitive, so a package can refer to the same repo as a row in repos while using a casing variant that was never inserted. Those rows skip the update and keep a mixed-case repository_url after repos is normalized, breaking the intended alignment with canonical lowercase URLs.
Reviewed by Cursor Bugbot for commit eff5795. Configure here.
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated no new comments.
Comments suppressed due to low confidence (1)
backend/src/osspckgs/migrations/V1784718693__merge_case_duplicate_github_repos.sql:112
- This key-mutating update is not CDC-safe for Tinybird:
repos.datasourceusesurlas its ReplacingMergeTree sorting key (services/libs/tinybird/datasources/repos.datasource:72-75), so the lowercase event cannot replace the old mixed-case key underFINAL. The migration mentions apackageReposrebuild, but the deployment must also rebuildrepos(and account for the deleted derived rows), otherwise the duplicates remain visible in Tinybird.
UPDATE repos r
SET url = LOWER(r.url), updated_at = NOW()
WHERE r.host = 'github'
AND r.url <> LOWER(r.url);
| UPDATE repos r | ||
| SET url = LOWER(r.url), updated_at = NOW() | ||
| WHERE r.host = 'github' | ||
| AND r.url <> LOWER(r.url); |


This pull request introduces a migration to clean up duplicate GitHub repositories in the
repostable, which arose due to case sensitivity issues in URLs. The migration consolidates duplicate entries by keeping a single canonical (lowercase) row per repository, re-points associated data, and enforces case-insensitive uniqueness for GitHub URLs going forward.Duplicate GitHub repository consolidation:
package_reposandrepo_dockerto the keeper repository, ensuring only one link per package/group combination, and removes redundant links.repo_scorecard_checks,security_contacts,repo_activity_snapshot) associated with loser repositories, as these will be regenerated as needed.repostable and normalizes the surviving repository URL to lowercase if needed.